package thread;

public class SyncTest1 {

    public synchronized void fun1() {
        try {
            Thread.sleep(1000 * 10);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("1");
    }

    public synchronized void fun2() {
        try {
            Thread.sleep(1000 * 2);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("2");
    }

    public SyncTest1() {

    }

    public static void main(String[] args) throws InterruptedException {
        SyncTest1 s = new SyncTest1();
        Runnable r1 = new Runnable() {
            @Override
            public void run() {
                s.fun1();
            }
        };
        Runnable r2 = new Runnable() {
            @Override
            public void run() {
                s.fun2();
            }
        };
        new Thread(r1).start();
        // Thread.sleep(1000);
        new Thread(r2).start();
        System.out.println(3);
    }
}
